package fr.ginvest.entity;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@Table(name = "demande")
public class Demande implements Serializable {

	private static final long serialVersionUID = -5465251696725324576L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO) 
	private int id;
	
	public enum Etat{NON_TRAITE, ACCEPTE, REFUSE}
	
	@Column(length=255)
	private String message;
	
	@Basic(optional=false)
	@Temporal(TemporalType.TIMESTAMP)
	private java.util.Date dateDemande;
	
	@Temporal(TemporalType.TIMESTAMP)
	private java.util.Date dateTraite;
	
	@Enumerated(EnumType.STRING)
	private Etat etat;
	
	public Demande() {}

	protected Demande(String message) {
		super();
		this.message = message;
		this.dateDemande = new java.util.Date();
		this.etat = Etat.NON_TRAITE;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Demande other = (Demande) obj;
		if (id != other.id)
			return false;
		return true;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public java.util.Date getDateDemande() {
		return dateDemande;
	}

	public void setDateDemande(java.util.Date dateDemande) {
		this.dateDemande = dateDemande;
	}

	public java.util.Date getDateTraite() {
		return dateTraite;
	}

	public void setDateTraite(java.util.Date dateTraite) {
		this.dateTraite = dateTraite;
	}

	public Etat getEtat() {
		return etat;
	}

	public void setEtat(Etat etat) {
		this.etat = etat;
	}
	
	

}
